!(function(){
    // 创建场景
    let scene = new THREE.Scene();
    // 创建摄像机
    let camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
    // 创建渲染对象
    let renderer = new THREE.WebGLRenderer({
      canvas: canvas,
      antialias: true,
    });
    renderer.shadowMap.enabled = true;
    // 设置渲染器的尺寸
    renderer.setSize(window.innerWidth, window.innerHeight);

    // 添加灯光处理
    let light = new THREE.AmbientLight(0xffffff);
    scene.add(light);

    let geometry = new THREE.BoxGeometry(3, 3, 3);
    // 加载纹理贴图
    let texture = new THREE.TextureLoader().load("images/mmm.jpg");
    let material = new THREE.MeshBasicMaterial({ map: texture });
    let box = new THREE.Mesh(geometry, material);

    box.position.set(0,0,0);

    scene.add(box);

    camera.position.set(0,0,20);
    camera.lookAt(box.position);

    function loop() {
        requestAnimationFrame(loop);

        box.rotation.x += 0.01;
        box.rotation.y += 0.01;
        box.rotation.z += 0.01;

        renderer.render(scene, camera);
    };

    loop();
})();